#include "Airport.h"

Airport::Airport()
{
	capacity=55;
}

Airport::Airport(char aName[20], int iks, int igrek, int ran, int cap, int rnways, int st)
{
	strcpy(airportName,aName);
	//airportName = aName;
	x = iks;
	y = igrek;
	range = ran;
	capacity = cap;
	runwaysNum = rnways;
	state = st;
}

Airport::~Airport()
{
	// here should be deleting vector of airports and vector of runways	
}

void Airport::addAircraft(Aircraft a)
{
	aircraftVector.push_back(a);	
}

void Airport::printInfo()
{
	std::cout << airportName << " At: " << x << " " << y << " With capacity: " << capacity << std::endl;
}

char * Airport::getName()
{
	return airportName;
}

void Airport::showAircraftsList()
{
	std::vector<Aircraft>::iterator iter;
	int counter=1;
	
	iter=aircraftVector.begin();
	while(iter!=aircraftVector.end())
	{
		std::cout << "No." << counter << " " ; 
		iter->getInfo();
		iter++;
		counter++;
	}
}

int Airport::getAircraftsNumber()
{
	return (aircraftVector.size());
}



void Airport::addRunway(Runway r)
{
	runwaysVector.push_back(r);

}

void Airport::showRunwaysStatus()
{
	std::vector<Runway>::iterator iter;
	int counter=0;

	iter=runwaysVector.begin();
	while(iter!=runwaysVector.end())
	{
		std::cout << "Runway No. " << runwaysVector[counter].getID();
		std::cout << " Status " << runwaysVector[counter].getStatus() << std::endl;
		iter++;
		counter++;	
	}
}


Aircraft Airport::getAircraftStructure(int number)
{
    return (aircraftVector[number]);
}

Runway Airport::getRunwayStructure(int number)
{
    return (runwaysVector[number]);
}

void Airport::deleteAircraft(char nam[20])
{
    std::vector<Aircraft>::iterator it;
    int siz;
    
    siz = aircraftVector.size();
    
    for(it=aircraftVector.begin(); it!=aircraftVector.end(); it++)
    {
	if(strcmp(it->getAircraftName(),nam)==0)
	{
	    // we've found it - so annihilate it ]:->
	    aircraftVector.erase(it);
	    aircraftVector.resize(siz-1);
	    return ;
	}
    }
}